const baes_url = 'https://api-hmugo-web.itheima.net/api/public/v1'

export default function (url, data, method='GET') {
    return new Promise((resolve, reject) => {
        uni.showLoading({
            title: '拼命加载中...',
            mask: true
        })
          
        uni.request({
            url: baes_url + url,
            data,
            method,
            header: {'content-type':'application/json'},
            success: (result) => {
                resolve(result.data)
            },
            fail: (err) => {
                reject(err)
            },
            complete: () => {
                uni.hideLoading();
            }
        });
    })    
}